package com.xudow.app.newui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xudow.app.R;
import com.xudow.app.newui.bean.MyGvBean;
import com.xudow.app.newui.view.MyGridView;

import java.util.List;


/**
 * Created by Administrator on 2016/8/14.
 */
public class GvAdapter extends BaseAdapter {
    Context context;
    List<MyGvBean> data;
    int resource;
    MyGridView myGridView;
    public GvAdapter(Context cxt,List<MyGvBean> array,int resource) {
        this.context=cxt;
        this.data=array;
        this.resource=resource;
    }

    @Override
    public int getCount() {
        if (null==data||data.size()==0)
            return 0;
        else
            return data.size();
    }

    @Override
    public MyGvBean getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (i==0)
            myGridView=(MyGridView)viewGroup;
        view=View.inflate(context,resource,null);
        TextView tv=(TextView) view.findViewById(R.id.tv);
        tv.setText(getItem(i).title);
        return view;
    }
}
